(function () {
  if ("sycm.taobao.com" === window.location.host) {
    const t = window.fetch;
    function i(i) {
      new Promise((e, t) => {
        var o = i.clone(),
          l = r(o.url),
          a = n(o.url);
        _intercepteConfig.intercepterUrl[l] &&
          o.json().then((i) => {
            _intercepteConfig.intercepterUrl[l].keepData({ p: a, d: i });
          });
      });
    }
    function e(i) {
      new Promise((e, t) => {
        var o = i.clone(),
          l = r(o.url),
          a = n(o.url);
        if (void 0 != _doFilter[l])
          for (var d = 0; d < _doFilter[l].params.length; d++) {
            var c = !0;
            for (var f in _doFilter[l].params[d])
              _doFilter[l].params[d][f] != a[f] && (c = !1);
            c &&
              ((i) => {
                o.json().then((e) => {
                  _doFilter[l].callback[
                    l + JSON.stringify(_doFilter[l].params[i])
                  ] &&
                    (_doFilter[l].callback[
                      l + JSON.stringify(_doFilter[l].params[i])
                    ]({ p: a, d: e }),
                    (_doFilter[l].callback[
                      l + JSON.stringify(_doFilter[l].params[i])
                    ] = void 0),
                    _doFilter[l].time--,
                    _doFilter[l].time < 0 && (_doFilter[l] = void 0));
                });
              })(d);
          }
      });
    }
    function r(i) {
      var e = null;
      if (void 0 == i) {
        e = window.location.href;
        var r = window.location.href.indexOf("#!/"),
          n = window.location.href.indexOf("?");
      } else {
        (r = i.indexOf("#!/")), (n = i.indexOf("?"));
        e = i;
      }
      if (-1 == e.indexOf("?")) var t = e.substring(r);
      else t = e.substring(r, n);
      return t;
    }
    function n(i) {
      if (void 0 == i)
        var e = window.location.href.indexOf("?"),
          r = window.location.href.substring(e + 1);
      else (e = i.indexOf("?")), (r = i.substring(e + 1));
      for (var n = r.split("&"), t = {}, o = 0; o < n.length; o++) {
        var l = n[o].split("=");
        2 == l.length ? (t[l[0]] = l[1]) : (t[l[0]] = "");
      }
      return t;
    }
    (_intercepteConfig = { intercepterUrl: {} }),
      (window._doFilter = {}),
      (window.fetch = function () {
        return new Promise((r, n) => {
          var o = t.apply(this, arguments);
          o.then((n) => {
            try {
              e(n), i(n);
            } catch (t) {
              console.log(t);
            } finally {
              r(n);
            }
          }).catch((i) => {
            n(i);
          });
        });
      });
  }
})();
